<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>参与单位详细信息</title>
<%@ include file="/common/meta.jsp"%>
<script type="text/javascript" src="${res}/js/proposal/irisPrpPrepare.js"></script>
<script type="text/javascript" src="${res}/js/validate/irisvalidator.js"></script>
<script type="text/javascript" src="${res}/js/autodisckey/autodisckey.js"></script>

<style type="text/css">
	.input_width { width:130px }
	.select_width { width:143px }
	.table_td td {border:0}
	.long_input{ width:642px }
    .selectWidth4{width:624px;}
</style>
<script type="text/javascript">
var type = "${param.type}";
var parentTable = parent.$("#"+"${param.parentTab}");	//父页面的表格
var selectRadio = $();									//父页面选中的单选框
var selectTr = $();										//父页面选中的行

if(type=="edit") {
	selectRadio = parentTable.find(":radio:checked");
	selectTr = selectRadio.parents("tr");
}

$(function(){
//	$("#fragment-tab1 :text,#fragment-tab1 [type='date']").addClass("input_width");
	//$("#fragment-tab1 select").addClass("select_width");
	
	if(type=="edit"){
		
		$("input:not(:radio:button),textarea").each(function(){

			var id=$(this).attr("name");
			if(id==null || id=="")
				return true;
			
			var parentObj=selectTr.find("[name$='/"+id+"']");
			var value="";
			if(parentObj.is("span"))
				value=parentObj.text();
			else
				value=parentObj.val();
			//if($(this).is("input"))//初始化input框 不包括radio
				$(this).val(value);
		});
		
		$(":radio").each(function(){//初始化radio框
			var name=$(this).attr("name");
		
			
			var value=$("[name='"+name+"_value']").val();
			if($(this).val()==value)
				$(this).attr("checked",true);
			
		});
		tree();
	}
	
	 function savePsn(){
		//填写检查接口
		validate($("#fragment-tab1"),"");
		if(!valResult()){
			irisValShowMsg($("#savePsn"));
			return false;
		}
		
		
		
		
		//添加新行
		if(type=="add") {
			addNewRowDeal(parentTable);
		}
		$("textarea").each(
				function() {
					var val = $(this).val();
					val = val.replace(/&/g, "&amp;").replace(/</g, "&lt;")
							.replace(/>/g, "&gt;").replace(/\n/g, "<br/>")
							.replace(/\s/g, "&nbsp;").replace(/"/g, "&quot;");
					$("input[name='" + $(this).attr('name') + "_hidden']").val(
							val);
				});
		$("input:not(:radio:button),textarea").each(function(){
			
			var id=$(this).attr("name");
			var parentObj=null;
			
			if(id==null || id=="")
				return true;
			
			//获得父页面的对象
			if(type=="add"){
				parentObj=parentTable.find("tr:last-child").find("[name$='/"+id+"']");
			}else if(type=="edit"){
				parentObj=selectTr.find("[name$='/"+id+"']");
				
			}

			if(parentObj!=null){
				if(parentObj.is("span")){
					parentObj.text($(this).val());	//将值写回父页面
				}
				else{
					parentObj.val($(this).val());
				}
			}
		});
		
		if(type=="add"){
			parentTable.find("tr:last :radio").attr("checked",true);
		}
		
		
		//if(confirm("保存成功，是否返回申请书页面"))
		//	parent.tb_remove();
		//else
		$(".wBox_popup").hide();
		if(confirm("保存成功，是否返回申请书页面")){
			parent.tb_remove();
		}
			
		else if(type=="add"){
			type = "edit";
			selectRadio = parentTable.find(":radio:checked");	//父页面选中的单选框
			selectTr = selectRadio.parents("tr");				//父页面选中的行
		}
	}
	$("#savePsn").click(function(){
		setTimeout(savePsn,100);
	}); 
});
function tree(){
	var nature_name=$("#nature_name").val(); 
	$("#nature").val(nature_name);
}

function loadAjaxSelect(selectId,url,params,varParm){
	$.ajax( {
		url : url,
		type : 'post',
		dataType:'json',
		data : params,
		success : function(data) {
			
			for(var i=0;i<data.length;i++){
				var value=data[i].id;
				var text=data[i].name;		
				$("#"+selectId).append("<option value='"+value+"'>"+text+"</option>");
				

			}
			if(type=="edit"){//如果是修改，才需要初始化select框的值
				var selectValue=$("[name='"+selectId+"_value']").val();
				$("#"+selectId+" option").each(function(i,obj){
					if($(obj).val()==selectValue){
						setTimeout(function() {
							$(obj).attr("selected",true);
						}, 1);
					}
				});
			}
		}
	});
	}




</script>
<script type="text/javascript">
function initTreeValueExt(treeId, treeNode) {
	   
	  if ((treeId == "nature" && treeNode && treeNode.isParent)) {
		  scmWarn("请选择具体的"+$("#" + treeId).attr("label"));
		if (treeNode.level == 0) {
			$("#" + treeId).val("");
			$("#" + treeId).parents("td").find("[name$='" + treeId + "_code'],[id$='" + treeId+ "_code']").val("");
			$("#" + treeId).parents("td").find("[name$='" + treeId + "_value'],[id$='" + treeId+ "_value']").val("");
			$("#" + treeId).parents("td").find("[name$='" + treeId + "_name'],[id$='" + treeId+ "_name']").val("");
		}
		
		return false;
		}
	
	
		var str = treeNode.name;
		var obj = treeNode.parentNode;
		while (obj != null) {
			obj = obj.parentNode;
		}
		
		$("#" + treeId).parents("td").find("[name$='" + treeId + "_code'],[id$='" + treeId+ "_code']").val(treeNode.id);
		$("#" + treeId).parents("td").find("[name$='" + treeId + "_value'],[id$='" + treeId+ "_value']").val(treeNode.id);
		$("#" + treeId).parents("td").find("[name$='" + treeId + "_name'],[id$='" + treeId+ "_name']").val(str);
		
	}
/**
 * 各类公用控件和radio框储存值到隐藏域中(除了tree和智能下拉框外)
 */
function initControlValue(objId){
	
		var name="";
		var obj=$("#"+objId);
	    if(obj.is("select")){
	    	name=obj.attr("name");
	    	obj.parent().children("input[name$='"+name+"_value'][type='hidden']").val($("#"+objId).find("option:selected").val());
	    	$("#"+objId).parent().children("input[name$='"+name+"_name']").val($("#"+objId).find("option:selected").text());
	    }
	   
	    else if(obj.is(":radio")){
	    	name=obj.attr("name");
	    	if(obj.is(":checked")){//如果被选中
	    		//alert($("#"+objId).val());		
	    		obj.parents("table").find("input[name$='"+name+"_value'][type='hidden']").val($("#"+objId).val());
	    		$("#"+objId).parent().children("input[name$='"+name+"_name']").val($("#"+objId).next().text());
	    	}
	    	else{
	    		
	    		obj.parents("table").find("input[name$='"+name+"_value'][type='hidden']").val("");
	    	}
	    }else if(obj.is(":checkbox")){
	    	name=obj.attr("name");
	    	if(obj.is(":checked"))//如果被选中
	    		obj.parent().find("input[name$='"+name+"_value'][type='hidden']").val($("#"+objId).val());
	    	else
	    		obj.parent().find("input[name$='"+name+"_value'][type='hidden']").val("");
	    }else{
	    	name=obj.attr("id");
	    	obj.parents("td").find("input[name$='"+name+"_name'][type='hidden']").val(obj.val());
	    	obj.parents("td").find("input[name$='"+name+"_code'][type='hidden']").val($("#"+objId+"_hideId").val());
	    }  	
}

function click1(){
	$("#neworg_type_name").val($("#ck1").html());
	$("#neworg_type_value").val($("#new_1").val());
}
function click2(){
	$("#neworg_type_name").val($("#ck2").html());
	$("#neworg_type_value").val($("#new_2").val());
}


</script>
</head>
<body>

	<div id="tabnav">
		<ul>
			<li class="down" id="tab1" onclick="changeTab(this.id)">
					<a href="###"><span>科技企业孵化器毕业企业一览表</span></a>
			</li>
		</ul>
	</div>
	
	<div class="tab_box" id="fragment-tab1">
		<table class="t_css table01" width="100%" border="0" cellpadding="0" label="" cellspacing="1">
	<tr   class="li_1">
		<td align="right"><span  class="color_red">*</span>企业名称：</td>
		<td  colspan="2">
		<input name="content1"  label="企业名称" type="text" class="required input_css " maxlength="100" value="" /></td>
		<td align="right"><span  class="color_red">*</span>主导产品：</td>
		<td><input name="content2"  label="主导产品" type="text" class="required input_css " maxlength="100" value="" /></td>
	</tr>
	<tr   class="li_2">
		<td align="right"><span  class="color_red">*</span>技术领域：</td>
		<td  colspan="2">
		<input name="content3"  label="技术领域" type="text" class="required input_css " maxlength="100" value="" /></td>
		<td align="right"><span  class="color_red">*</span>拥有自主知识产权数：</td>
		<td><input name="content4"  label="拥有自主知识产权数" type="text" class="required input_css " style="text-align:right;"  onfocus="InitInput.setNumber(this,7,0,0)" maxlength="100" value="" /></td>
	</tr>
	<tr class="li_1">
		<td align="right" ><span  class="color_red">*</span>进驻时间：</td>
		<td colspan="2">
		<cpt:date id="jinzhu_date"  value="" className="required date" label="进驻时间"   name="jinzhu_date" ></cpt:date> 
			<input type='hidden' name='date' id='date' value=""/>
		</td>
		<td align="right" ><span  class="color_red">*</span>毕业时间：</td>
		<td colspan="1">
		<cpt:date id="biye_date"  value="" className="required date" label="毕业时间"   name="biye_date" ></cpt:date> 
			<input type='hidden' name='date' id='date' value=""/>
		</td>
	</tr>
	<tr class="li_2">
		<td align="right" ><span  class="color_red">*</span>毕业时是否为高新技术企业</td>
		<td colspan="4">
		<label> <input type="radio" class="do " id="new_1" style="vertical-align: middle;" name="neworg_type" label="是" value="1" onclick="click1(this)"/><span style="vertical-align: middle;" id="ck1">是</span></label> 
		<label> <input type="radio" class="do " id="new_2" style="vertical-align: middle;" name="neworg_type" label="否" value="2" onclick="click2(this)"/><span style="vertical-align: middle;" id="ck2">否</span></label> 
		<input type="hidden" name="neworg_type_value" id="neworg_type_value" class="required" value="" label="毕业时是否为高新技术企业" /> 
		<input type="hidden" name="neworg_type_name" id="neworg_type_name" value="" />
		</td>
	</tr>
	<tr   class="li_1">
		<td align="right"><span  class="color_red">*</span>上两个年度营业收入（万元）：</td>
		<td  colspan="2">
		<input name="content7"  label="上两个年度营业收入" type="text" class="required input_css "style="text-align:right;" onfocus="InitInput.setNumber(this,7,2,2)" value="" /></td>
		<td align="right"><span  class="color_red">*</span>上年末职工数(人)：</td>
		<td><input name="content8"  label="上年末职工数" type="text" class="required input_css "style="text-align:right;" onfocus="InitInput.setNumber(this,7,0,0)" value="" /></td>
	</tr>
	
	</table>
	</div>

	<table width="100%" align="center">
		<tr>
			<td><input type="button"  class="button_01 notdisabled" id="savePsn" value="保存">
				&nbsp;<input type="button" id="cancel" class="button_01 notdisabled" value="取消" onclick="parent.tb_remove();">
			</td>
		</tr>
	</table>
	<br />
</body>
</html>